import { Map } from 'immutable';
import * as  types from './constans'

const initState = Map({
  token: '',
  profile: {}
})

export default (state = initState, actions: any) => {
  switch (actions.type) {
    case types.SAVE_TOKEN:
      return state.set('token', actions.payload);
    case types.SAVE_PROFILE:
      return state.merge({
        token: actions.payload.token,
        profile: actions.payload
      })
    default:
      return state
  }
}